const app = getApp();

Page({
  data: {
    title: "",
    score: 0
  },
  onLoad: function () {
    this.setData({
      title: app.globalData.title,
      score: app.globalData.score
    });
    wx.getUserInfo({
      success: res => {
        console.error('获取用户信息', res);
        this.setData({
          userInfo: res.userInfo
        });
      },
      fail: err => {
        console.error('获取用户信息失败', err);
      }
    });
  },
  onShow: function() {
    this.setData({
        title: app.globalData.title,
        score: app.globalData.score
      });
  },
  navigateToQuestion: function (e) {
    app.playSound('next');
    const level = e.currentTarget.dataset.level;
    wx.navigateTo({
      url: `/pages/question/question?level=${level}`
    });
  },
  navigateToSolve: function (e) {
    app.playSound('next');
    wx.navigateTo({
      url: `/pages/solve/solve`
    });
  }
});